﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace Meraz.Core.Model
{
    public class TwitterStudy : Study, IEquatable<TwitterStudy>
    {
        public TwitterStudy() {
            TwitterUserNames = new List<string>();
            TwitterUsers = new List<TwitterUser>();
        }

        public virtual List<TwitterUser> TwitterUsers { get; set; }
        public List<string> TwitterUserNames { get; set; }

        public void SyncUsers()
        {
            TwitterUserNames.Clear();
            TwitterUserNames = TwitterUsers.Select(select1 => select1.Name).ToList();
            TwitterUserNames.Sort();
        }

        public void AddUser(TwitterUser user)
        {
            if (TwitterUsers == null)
                TwitterUsers = new List<TwitterUser>();
            if (TwitterUsers.Contains(user))
                return;
            TwitterUsers.Add(user);
        }
        public void RemoveUser(string username)
        {
            if (TwitterUsers == null)
                return;
            TwitterUser user = new TwitterUser();
            user.Name = username;
            TwitterUsers.Remove(user);
        }
        #region IEquatable<TwitterStudy> Members

        public bool Equals(TwitterStudy other)
        {
            if (other == null)
                return false;
            return this.ID.Equals(other.ID);
        }

        #endregion
    }
}
